package GenericData.service.impl;

import GenericData.entity.User;
import GenericData.service.GenericDAO;

import java.util.ArrayList;
import java.util.List;

/*
 * Author: JacksonCoder
 * FileName: UserDAO
 * Version: 1.0.0
 */
public class UserDAO implements GenericDAO<User> {
    private List<User> users = new ArrayList<>();

    @Override
    public void save(User entity) {
        users.add(entity);
    }

    @Override
    public User findById(int id) {
        return users.stream()
                .filter(user -> user.getId() == id)
                .findFirst()
                .orElse(null);
    }

    @Override
    public List<User> findAll() {
        return users;
    }
}
